class NSUserInfoModel {
  String? token; // 用户登录令牌
  String? isFirstRegister; // 是否为第一次注册
  String? userId; // 用户ID

  String? avatarUrl; // 头像
  String? avatarMiddleThumbUrl; // 中等大小头像
  String? avatarThumbUrl; // 头像缩略图

  int? gender; // 性别
  String? nickname; // 昵称
  int? age; // 年龄
  String? birthday; // 生日
  String? country; // 国家
  String? about; // 个人介绍

  bool? isVip; // 用户是否为VID
  String? vipLevel; // 用户VIP等级
  String? vipExpiryTime; // 用户VIP过期时间

  bool? isBlock; // 是否被拉黑
  bool? isFriend; // 是否是好友

  String? onlineStatus; // 在线状态

  String? rongcloudToken; // 融云Token

  List<MediaModel>? mediaList; // 用户照片墙列表
  //
  // RCIMIWMessage? lastMessage; // 最后一条收到的消息
  int? availableCoins;
  NSUserInfoModel({
    this.token,
    this.isFirstRegister,
    this.userId,
    this.avatarUrl,
    this.avatarMiddleThumbUrl,
    this.avatarThumbUrl,
    this.gender,
    this.nickname,
    this.age,
    this.birthday,
    this.country,
    this.about,
    this.isVip,
    this.vipLevel,
    this.vipExpiryTime,
    this.isBlock,
    this.isFriend,
    this.onlineStatus,
    this.rongcloudToken,
    this.mediaList,
    this.availableCoins
    // this.lastMessage,
  });

  NSUserInfoModel.fromJson(dynamic json) {
    token = json['token'];
    isFirstRegister = json['isFirstRegister'];
    userId = json['userId']??json['broadcasterId'];
    avatarUrl = json['avatarUrl'];
    avatarMiddleThumbUrl = json['avatarMiddleThumbUrl'];
    avatarThumbUrl = json['avatarThumbUrl'];
    gender = json['gender'];
    nickname = json['nickname']??json['nickName'];
    age = json['age'];
    birthday = json['birthday'];
    country = json['country']??json['registerCountry'];
    about = json['about'];
    isVip = json['isVip'];
    vipLevel = json['vipLevel'];
    vipExpiryTime = json['vipExpiryTime'];
    isBlock = json['isBlock'];
    isFriend = json['isFriend'];
    onlineStatus = json['onlineStatus'];
    rongcloudToken = json['rongcloudToken'];
    if (json['mediaList'] != null) {
      mediaList = [];
      json['mediaList'].forEach((v) {
        mediaList!.add(MediaModel.fromJson(v));
      });
    }
    availableCoins = json['availableCoins'];
    // lastMessage = json['lastMessage'] != null
  }

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['token'] = token;
    map['isFirstRegister'] = isFirstRegister;
    map['userId'] = userId;
    map['avatarUrl'] = avatarUrl;
    map['avatarMiddleThumbUrl'] = avatarMiddleThumbUrl;
    map['avatarThumbUrl'] = avatarThumbUrl;
    map['gender'] = gender;
    map['nickname'] = nickname;
    map['age'] = age;
    map['birthday'] = birthday;
    map['country'] = country;
    map['about'] = about;
    map['isVip'] = isVip;
    map['vipLevel'] = vipLevel;
    map['vipExpiryTime'] = vipExpiryTime;
    map['isBlock'] = isBlock;
    map['isFriend'] = isFriend;
    map['onlineStatus'] = onlineStatus;
    map['rongcloudToken'] = rongcloudToken;
    if (mediaList != null) {
      map['mediaList'] = mediaList!.map((v) => v.toJson()).toList();
    }
    map['availableCoins'] = availableCoins;
    // map['lastMessage'] = lastMessage == null ? null : lastMessage!.toJson();
    return map;
  }
}

/// 用户媒体信息模型
class MediaModel {
  String? mediaId; // 媒体资源ID
  String? mediaPath; // 媒体资源文件路径
  String? mediaType; // 媒体资源类型
  String? mediaUrl; // 媒体资源地址
  String? middleThumbUrl; // 中等尺寸媒体资源地址
  dynamic? sort; // 资源排序
  String? thumbUrl; // 媒体资源缩略图地址
  String? userId; // 归属的用户ID

  MediaModel({
    this.mediaId,
    this.mediaPath,
    this.mediaType,
    this.mediaUrl,
    this.middleThumbUrl,
    this.sort,
    this.thumbUrl,
    this.userId,
  });

  MediaModel.fromJson(dynamic json) {
    mediaId = json['mediaId'];
    mediaPath = json['mediaPath'];
    mediaType = json['mediaType'];
    mediaUrl = json['mediaUrl'];
    middleThumbUrl = json['middleThumbUrl'];
    sort = json['sort'];
    thumbUrl = json['thumbUrl'];
    userId = json['userId'];
  }

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['mediaId'] = mediaId;
    map['mediaPath'] = mediaPath;
    map['mediaType'] = mediaType;
    map['mediaUrl'] = mediaUrl;
    map['middleThumbUrl'] = middleThumbUrl;
    map['sort'] = sort;
    map['thumbUrl'] = thumbUrl;
    map['userId'] = userId;
    return map;
  }
}
